import { pay } from '@/api/goodIndent'

export default {
  layout: 'com',
  // middleware: 'auth',
  head () {
    return {
      title: this.$t('money.success') + '-' + process.env.APP_NAME,
    }
  },
  data() {
    return {
      payMsg: "결제확인중"
    }
  },
  mounted() {
    this.go()
    // $nuxt.$store.commit('setCartTitle', this.$t('money.success'));
  },
  methods: {
    go(path){
      pay($nuxt.$route.query.id).then(response => {
        console.log("🚀 ~  response: ", response)
        if (response.state !== 1) {  // 订单发生改变时，直接跳转到结果页
          // if (response.state === 4) {
          //   this.payMsg = '결제가 실패되었습니다!'
          //   // 
          // } else {
          //   console.log(222)
          //   this.payMsg = '결제가 완료되었습니다!'
          // }
          window.location.replace('https://www.drk88.com/user/indent/list')
        } else {
          this.payMsg = '결제가 실패되었습니다!'
          console.log('未付款')
        }
      }).catch(error => {
      })
    }
  }
}
